﻿//**************************************包含获取网站的相关属性的方法***************************
var MyWebsite = {
    getServerAddr: function () {
        /// <summary>获取服务器的Url；返回的字符串最后包含斜杠符号“/”</summary>
        return window.location.protocol + "//" + this.getHost() + "/";
    },
    getHost: function () {
        /// <summary>获取Web服务器的IP:Port, 如: http://127.0.0.1:8225/
        ///在安全连接的情况下，某些时候host中会自动出现443端口，而实际是80端口</summary>
        var sHost = window.location.host;
        if (!sHost) {
            sHost = top.location.host;
        }
        if (sHost.indexOf(":443") >= 0)
            sHost = sHost.replace(":443", "");
        return sHost;
    },
    getQueryParam: function (sName, sQueryString) {
        /// <summary>获取QueryString的值</summary>
        /// <param name="sName" type="String">对应的键</param>
        /// <param name="sQueryString" type="String">不传入则默认获取当前页面的查询字符串的值</param>
        var match = RegExp(sName + '=([^&]*)').exec(sQueryString || location.search);
        return match && decodeURIComponent(match[1]);
    }
};

